package me.helllp.bootman.back.config;

import java.util.Properties;

import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import tk.mybatis.spring.mapper.MapperScannerConfigurer;

@Configuration
@AutoConfigureAfter(MyBatisConfig.class)
public class MapperScanner {
    //	通用Mapper的配置
    @Bean
    public MapperScannerConfigurer mapperScannerConfigurer() {
        //	此处使用的是tk.mybatis.spring.mapper.MapperScannerConfigurer
        MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
        
        mapperScannerConfigurer.setMarkerInterface(BootmanMapper.class);
        mapperScannerConfigurer.setBasePackage("me.helllp.bootman.mapper");
        
        Properties properties = new Properties();
        
        //	notEmpty：insert和update中，是否判断字符串类型!=''，少数方法会用到
        properties.put("notEmpty", false);
        //	取回主键的方式
        properties.put("IDENTITY", "MYSQL");
        //	实体和表转换时的约定规则，默认驼峰转下划线。注解@Table和@Column优先级高于此配置
        properties.put("style", "camelhump");

        mapperScannerConfigurer.setProperties(properties);
        
        return mapperScannerConfigurer;
    }
}
